module ran001
  implicit none
  save
  integer  :: n = 9876
end module ran001

subroutine random0 (ran)
  use ran001
  implicit none
  real, intent(out) :: ran
  n = mod (8121*n + 28411, 134456)
  ran = real(n)/134456.0
end subroutine random0

subroutine seed (iseed)
  use ran001
  implicit none
  integer, intent(in) :: iseed
  n = abs(iseed)
end subroutine seed

program test_random0
  real :: ave, ran, sum
  integer :: i, iseed, iseq

  ! get seed
  write(*,*)   'enter seed: '
  read(*,*)  iseed

  call seed(iseed)

  write(*,*) '10  random numbers'
  do i = 1, 10
     call random0(ran)
     write(*, '(3x, f16.6)') ran
  end do
  
  write(*,*) 'averge of 1000 sequences'
  do iseq = 1, 5
     sum = 0
     do i = 1, 1000
        call random0(ran)
        sum = sum + ran
     end do
     ave = sum/1000.0
     write(*,'(3x, f16.6)') ave
  end do

end program test_random0
